﻿#ifndef USER_H
#define USER_H

#include <QObject>
#include <QJsonObject>
#include "tools.h"

class User : public QObject
{
    Q_OBJECT
public:
    explicit User(QObject *parent = nullptr);

    int id;
    QString username;
    QString password;
    QString operatePassword;
    QString companyId;
    QString nickName;
    QString tel;
    QString mobile;
    QString position;
    QString wechat;
    QString QQ;
    int permission;
    int isBoss;
    QString endDate;
    int credit;
    QString upUsername1;
    QString upUsername2;
    QString upUsername3;
    QString upUsername4;
    QString upUsername5;

    void loadFromJsonObject(QJsonObject obj);

    void saveToSettings();

    QString toJson();

    static void setIsSave(bool isSave){
        MySettings.setValue("user/isSave", isSave);
    }

    static bool getIsSave(){
        return MySettings.value("user/isSave").toBool();
    }

    static void setUsername(QString username){
        MySettings.setValue("user/username", username);
    }

    static QString getUsername(){
        return MySettings.value("user/username").toString();
    }

    static void setPassword(QString password){
        MySettings.setValue("user/password", password);
    }

    static QString getPassword(){
        return MySettings.value("user/password").toString();
    }

    static void setOperatePassword(QString operatePassword){
        MySettings.setValue("user/operatePassword", operatePassword);
    }

    static QString getOperatePassword(){
        return MySettings.value("user/operatePassword").toString();
    }

    static void setCompanyId(QString companyId){
        MySettings.setValue("user/companyId", companyId);
    }

    static QString getCompanyId(){
        return MySettings.value("user/companyId", "").toString();
    }

    static void setNickName(QString nickName){
        MySettings.setValue("user/nickName", nickName);
    }

    static QString getNickName(){
        return MySettings.value("user/nickName").toString();
    }

    static void setPosition(QString positin){
        MySettings.setValue("user/position", positin);
    }

    static QString getPosition(){
        return MySettings.value("user/position").toString();
    }

    static void setTel(QString tel){
        MySettings.setValue("user/tel", tel);
    }

    static QString getTel(){
        return MySettings.value("user/tel").toString();
    }

    static void setMobile(QString mobile){
        MySettings.setValue("user/mobile", mobile);
    }

    static QString getMobile(){
        return MySettings.value("user/mobile").toString();
    }

    static void setQQ(QString QQ){
        MySettings.setValue("user/QQ", QQ);
    }

    static QString getQQ(){
        return MySettings.value("user/QQ").toString();
    }

    static void setWechat(QString wechat){
        MySettings.setValue("user/wechat", wechat);
    }

    static QString getWechat(){
        return MySettings.value("user/wechat").toString();
    }

    static void setCredit(int credit){
        MySettings.setValue("user/credit", credit);
    }

    static int getCredit(){
        return MySettings.value("user/credit").toInt();
    }

    static void setEndDate(QString endDate){
        MySettings.setValue("user/endDate", endDate);
    }

    static QString getEndDate(){
        return MySettings.value("user/endDate").toString();
    }

    static void setIsBoos(bool isBoss){
        MySettings.setValue("user/isBoss", isBoss);
    }

    static bool getIsBoss(){
        return MySettings.value("user/isBoss").toBool();
    }
signals:

public slots:
};

#endif // USER_H
